home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / C / Comet2.1.3.cpt / emlib / prettywind.c < prev    next >
Text File  |  1991-04-01  |  16KB  |  791 lines

  1. /*
  2.     Copyright Cornell University 1986.  All rights are reserved.
  3.     
  4.     prettywind.c routines handle drawing of the window frame,
  5.     status labels, .
  6.     
  7.     (emcursor.c routines handle drawing and manipulatation of the q3 controls.)
  8. */
  9.  
  10. #include <em.h>
  11.  
  12. #include <h19.h>
  13. #include <rcodes.h>
  14. #include <resdefs.h>
  15.  
  16. Rect largerect;
  17. RgnHandle soldclip;                /* for save/restore functions */
  18. short oldfontsize;                /* for save/restore functions */
  19.  
  20. #define saveclip()
  21. #define restoreclip()
  22.  
  23. /* these defines set the top/bottom rectangle for the above label rects */
  24.  
  25. #define PWLEFTMARG    486
  26. #define PWRIGHTMARG    497
  27.  
  28. #define PWSHRINKTOP    10
  29. #define PWSHRINKBOT    33
  30.  
  31. #define PWSYSLOCKTOP    60
  32. #define PWSYSLOCKBOT    97
  33.  
  34. #define PWKBDLOCKTOP    110
  35. #define PWKBDLOCKBOT    147 
  36.  
  37. #define PWSHIFTTOP  160
  38. #define PWSHIFTBOT  197
  39.  
  40. #define PWRECORDTOP   219        /* picture of tape cassette indicating record mode */
  41. #define PWRECORDBOT   230
  42.  
  43. #define PWDUBSHIFTTOP   236
  44. #define PWDUBSHIFTBOT   276
  45.  
  46. #define PWMACROTOP      276
  47. #define PWMACROBOT      287
  48.  
  49.  
  50. /*    draw the window frame, title, controls, and various labels we need;
  51.     assumes window pointer is set */
  52.  
  53. prettywind(drawcontrols)
  54. {
  55.  
  56.     char achar;
  57.     short count;
  58.     Rect fillrect;
  59.     Rect paintrect;
  60.     short xpos, ypos;
  61.     struct fontsave ofont;
  62.     RGBColor forecolor;
  63.     
  64.     savefont(&ofont);
  65.     saveclip();
  66.  
  67.     if (emdp->color) {
  68.         /* fill the screen with the normal background color */
  69.         paintrect.top = -5;
  70.         paintrect.left = -3;
  71.         paintrect.bottom = emwindow->portRect.bottom;
  72.         paintrect.right = emdp->h19right - 7;
  73.     
  74.         GetForeColor(&forecolor);
  75.         
  76.         RGBForeColor(&emdp->ibmcolormap.colors[1]);        /* normal background */
  77.         PaintRect(&paintrect);
  78.         RGBForeColor(&forecolor);
  79.     }
  80.     
  81.     /* top */
  82.     MoveTo((short) -10, (short) -29);
  83.     Line((short) 1000, (short) 0);
  84.         /* double line at top */
  85.  
  86.     MoveTo((short) -10, (short) -5);
  87.     LineTo((short) 1000, (short) -5);
  88.         /* line at top of h19 screen */
  89.  
  90.     /* gray out the top as a background for buttons */
  91.     if ( ! line25on(emdp) && (emdp->controlschanged || !emdp->dsdraw)) {
  92.         /* the buttons can be shared with prompts, if the prompts are on,
  93.             don't gray it out */
  94.         FillRect(&emdp->toprect, gray);
  95.     }
  96.  
  97.     /* draw a title over the top, if there is one
  98.     if (!drawcontrols) {
  99.         count = strlen(screentitle);
  100.         pr25(35 - (count/2), screentitle);
  101.     }
  102.      */
  103.  
  104.     /* left */
  105.     if (drawcontrols) {
  106.         /* draw question mark button */
  107.         MoveTo((short) -9, (short) -12);
  108.         DrawChar('?');
  109.  
  110.  
  111.         /* draw 3rd quadrant buttons */
  112.             /* bottom - top == 20, * 12 boxes == height of window */
  113.         showq3buttons();
  114.     }
  115.     else {
  116.         /* gray the left side out */
  117.         fillrect.top = -30;
  118.         fillrect.left = -10;
  119.         fillrect.bottom = 300;
  120.         fillrect.right = -3;    /* was -3 */
  121.         FillRect(&fillrect, gray);
  122.     }
  123.     MoveTo((short) -3, (short) -30);
  124.     Line((short) 0, (short) 1000);
  125.         /* line at right edge of 3rd quad buttons */
  126.  
  127.     /* bottom */
  128.     MoveTo((short) (emdp->h19right - 7), (short) -5);
  129.     Line((short) 0, (short) 1000);
  130.         /* line at right edge, forming box for status lights/shrink button  */
  131.  
  132.     restoreclip();
  133.     restorefont(&ofont);
  134.  
  135.     /* draw the other flags -- must be outside of previous save/restore clip */
  136.     showshrink();
  137.     if (emdp->pfshift) 
  138.         pfshowshift();
  139.  
  140.     showtape();
  141.     if (emdp->dokeymacros)
  142.         showmacroflag();
  143.  
  144. #ifdef SHOWDOUBLESHIFT    
  145.     /* IBM PF double shift is not used, so... use the space for Macro label */
  146.     if (emdp->pfdubshift) 
  147.         pfshowdubshift();
  148. #endif
  149.  
  150. }
  151.  
  152. /* display a number in the left side of the right end of the top control bar */
  153.  
  154. drawversion(verstr)
  155. char * verstr;
  156. {
  157.     RgnHandle oldclip;
  158.     GrafPtr oport;
  159.  
  160.     if (emwindow == NULL)
  161.         return;
  162.  
  163.     GetPort(&oport);
  164.     SetPort(emwindow);
  165.  
  166.     /* reset clip to area we're drawing in  */
  167.     oldclip = NewRgn();
  168.     GetClip(oldclip);
  169.  
  170.     ClipRect(&emdp->countrect);
  171.     EraseRect(&emdp->countrect);
  172.  
  173.     /* draw box around input and output packet counters */
  174.     MoveTo((short) (emdp->countrect.left + 1), emdp->countrect.top);
  175.     LineTo((short) (emdp->countrect.left + 1), (short) -5);    /* double line at left too */
  176.     FrameRect(&emdp->countrect);
  177.  
  178.     SetClip(oldclip);
  179.     DisposeRgn(oldclip);
  180.     SetPort(oport);
  181. }
  182.  
  183.  
  184. /* display a number (packets received)
  185.     in the right side of the right end of the top control bar */
  186.  
  187. drawincount()
  188. {
  189.     char scount[11];
  190.     RgnHandle oldclip;
  191.     GrafPtr oport;
  192.     struct fontsave ofont;
  193.  
  194.     if (emwindow == NULL)
  195.         return;
  196.     
  197.     /* reset clip to area we're drawing in  */
  198.     GetPort(&oport);
  199.     SetPort(emwindow);
  200.     oldclip = NewRgn();
  201.     GetClip(oldclip);
  202.  
  203.     savefont(&ofont);    
  204.     ClipRect(&emdp->incountrect);
  205.  
  206. /*    EraseRect(&emdp->incountrect); */
  207.     MoveTo((short) (emdp->incountrect.left + 3), (short) -12);
  208.     if (emdp->conntype == CONN_MACTCP || emdp->conntype == CONN_CUTCP)
  209.         /* # of packets */
  210.         sprintf(scount, "%10D", emdp->in_cnt);
  211.     else
  212.         /* # of kilo-chars */
  213.         sprintf(scount, "%10D", emdp->kin_cnt);
  214.         
  215.     DrawText(scount, 5, 5);
  216.  
  217.     restorefont(&ofont);
  218.     SetClip(oldclip);
  219.     DisposeRgn(oldclip);
  220.     SetPort(oport);
  221. }
  222.  
  223.  
  224.  
  225. /* display a number (output packet count)
  226.     in the left side of the right end of the top control bar */
  227.  
  228. drawoutcount()
  229. {
  230.     long count;
  231.     char scount[11];
  232.     RgnHandle oldclip;
  233.     struct fontsave ofont;
  234.     GrafPtr oport;
  235.  
  236.     if (emwindow == NULL)
  237.         return;
  238.     
  239.     if (emdp->resending) {
  240.         drawinvoutcount();
  241.         return;
  242.     }
  243.     
  244.     count = emdp->out_cnt;
  245.     
  246.     /* reset clip to area we're drawing in  */
  247.     GetPort(&oport);
  248.     SetPort(emwindow);
  249.     oldclip = NewRgn();
  250.     GetClip(oldclip);
  251.  
  252.     savefont(&ofont);    
  253.     ClipRect(&emdp->outcountrect);
  254. /*    EraseRect(&emdp->outcountrect); */
  255.     MoveTo((short) (emdp->outcountrect.left + 3),(short) -12);
  256.     sprintf(scount, "%10D", count);
  257.     DrawText(scount, (short) 5, (short) 5);
  258.  
  259.     restorefont(&ofont);
  260.  
  261.     SetClip(oldclip);
  262.     DisposeRgn(oldclip);
  263.     SetPort(oport);
  264. }
  265.  
  266. /* display a number (output packet count)
  267.     in the left side of the right end of the top control bar */
  268.  
  269. drawinvoutcount()
  270. {
  271.     long count;
  272.     char scount[11];
  273.     RgnHandle oldclip;
  274.     struct fontsave ofont;
  275.     GrafPtr oport;
  276.  
  277.     if (emwindow == NULL)
  278.         return;
  279.         
  280.     count = emdp->out_cnt;
  281.  
  282.     /* reset clip to area we're drawing in  */
  283.     GetPort(&oport);
  284.     SetPort(emwindow);
  285.     oldclip = NewRgn();
  286.     GetClip(oldclip);
  287.  
  288.     savefont(&ofont);    
  289.     ClipRect(&emdp->outcountrect);
  290. /*    EraseRect(&emdp->outcountrect); */
  291.     MoveTo((short) (emdp->outcountrect.left + 3),(short) -12);
  292.     sprintf(scount, "%10D", count);
  293.     
  294.     TextMode(notSrcCopy);                        /* invert the font */
  295.     DrawText(scount, (short) 5, (short) 5);
  296.     TextMode(srcCopy);
  297.  
  298.     restorefont(&ofont);
  299.  
  300.     SetClip(oldclip);
  301.     DisposeRgn(oldclip);
  302.     SetPort(oport);
  303. }
  304.  
  305. /* initialize the shrink rectangle */
  306.  
  307. /* draw a collapsing rectangle a la the Zoom Box */
  308.  
  309. showshrink()
  310. {
  311.     Rect shrinkt;
  312.     
  313.     saveclip();
  314.     DrawPicture(shrinkpict, &emdp->shrinkrect);
  315.     restoreclip();
  316. }
  317.  
  318. /* draw a collapsing rectangle a la the Zoom Box */
  319.  
  320. showtape()
  321. {
  322.     Rect taperect;
  323.     
  324.     taperect.top = PWRECORDTOP;
  325.     taperect.left = emdp->h19flagcenter - 4;
  326.     taperect.bottom = PWRECORDBOT;
  327.     taperect.right = taperect.left + 13;
  328.     
  329.     saveclip();
  330.     if (emdp->logsession)
  331.         DrawPicture(tapepict, &taperect);
  332.     else
  333.         EraseRect(&taperect);
  334.         
  335.     restoreclip();
  336. }
  337.  
  338. /* display pf shift on */
  339.  
  340. pfshowshift()
  341. {
  342.     struct fontsave ofont;
  343.     
  344.     savefont(&ofont);
  345.     saveclip();
  346.  
  347.     FrameRect(&emdp->shiftrect);
  348.  
  349.     MoveTo(emdp->h19flagcenter, (short) (PWSHIFTTOP + 10));
  350.     DrawChar('^');
  351.     MoveTo(emdp->h19flagcenter, (short) (PWSHIFTTOP + 19));
  352.     DrawChar('P');
  353.     MoveTo(emdp->h19flagcenter, (short) (PWSHIFTTOP + 30));
  354.     DrawChar('F');
  355.  
  356.     restoreclip();
  357.     restorefont(&ofont);
  358. }
  359.  
  360. /* clear pf shift display */
  361.  
  362. pfclrshift()
  363. {
  364.     saveclip();
  365.     EraseRect(&emdp->shiftrect);
  366.     restoreclip();
  367. }
  368.  
  369.  
  370. /* show a pf double shift on the display */
  371.  
  372. showaltmacro()
  373. {
  374.     struct fontsave ofont;
  375.     
  376.     savefont(&ofont);
  377.     saveclip();
  378.  
  379.     MoveTo(emdp->h19flagcenter, (short) (PWDUBSHIFTTOP + 10));
  380.     DrawChar('A');
  381.     MoveTo(emdp->h19flagcenter, (short) (PWDUBSHIFTTOP + 21));
  382.     DrawChar('l');
  383.     MoveTo(emdp->h19flagcenter, (short) (PWDUBSHIFTTOP + 32));
  384.     DrawChar('t');
  385.  
  386.     if (emdp->macroexecuting)
  387.         InvertRect(&emdp->dubshiftrect);
  388.     else
  389.         FrameRect(&emdp->dubshiftrect);
  390.  
  391.     restoreclip();
  392.     restorefont(&ofont);
  393. }
  394.  
  395. /* clear the macro ALT flag from the display */
  396.  
  397. clraltmacro()
  398. {
  399.     saveclip();
  400.     EraseRect(&emdp->dubshiftrect);
  401.     restoreclip();
  402. }
  403.  
  404.  
  405. /* display macro interpretation on */
  406.  
  407. showmacroflag()
  408. {
  409.     struct fontsave ofont;
  410.     
  411.     if (emdp->keyaltset) 
  412.         showaltmacro();
  413.     else
  414.         clraltmacro();
  415.         
  416.     savefont(&ofont);
  417.     saveclip();
  418.     
  419.     EraseRect(&emdp->macrorect);
  420.     TextMode(srcOr);
  421.  
  422.     MoveTo(emdp->h19flagcenter, (short) (PWMACROTOP + 9));
  423.     DrawChar('M');
  424.     
  425.     if (emdp->macroexecuting)
  426.         InvertRect(&emdp->macrorect);
  427.     else
  428.         FrameRect(&emdp->macrorect);
  429.  
  430.     TextMode(srcCopy);
  431.     restoreclip();
  432.     restorefont(&ofont);
  433. }
  434.  
  435. /* clear macro on display */
  436.  
  437. clrmacroflag()
  438. {
  439.     clraltmacro();
  440.  
  441.     saveclip();
  442.     EraseRect(&emdp->macrorect);
  443.     restoreclip();
  444. }
  445.  
  446.  
  447. showsyslock()
  448. {
  449.     struct fontsave ofont;
  450.     
  451.     savefont(&ofont);
  452.     saveclip();
  453.     FrameRect(&emdp->syslockrect);
  454.     MoveTo(emdp->h19flagcenter, (short) (PWSYSLOCKTOP + 10));
  455.     DrawChar('S');
  456.     MoveTo(emdp->h19flagcenter, (short) (PWSYSLOCKTOP + 21));
  457.     DrawChar('Y');
  458.     MoveTo(emdp->h19flagcenter, (short) (PWSYSLOCKTOP + 32));
  459.     DrawChar('S');
  460.     restoreclip();
  461.     restorefont(&ofont);
  462. }
  463.  
  464. clrsyslock()
  465. {
  466.     saveclip();
  467.     EraseRect(&emdp->syslockrect);
  468.     restoreclip();
  469. }
  470.  
  471.  
  472. showkbdlock()
  473. {
  474.     struct fontsave ofont;
  475.     
  476.     /* display keyboard locked    */
  477.     savefont(&ofont);
  478.     saveclip();
  479.  
  480.     FrameRect(&emdp->kbdlockrect);
  481.  
  482.     MoveTo(emdp->h19flagcenter, (short) (PWKBDLOCKTOP + 10));
  483.     DrawChar('K');
  484.     MoveTo(emdp->h19flagcenter, (short) (PWKBDLOCKTOP + 21));
  485.     DrawChar('B');
  486.     MoveTo(emdp->h19flagcenter, (short) (PWKBDLOCKTOP + 32));
  487.     DrawChar('D');
  488.     restoreclip();
  489.     restorefont(&ofont);
  490. }
  491.  
  492. clrkbdlock()
  493. {
  494.     saveclip();
  495.     EraseRect(&emdp->kbdlockrect);
  496.     restoreclip();
  497. }
  498.  
  499.  
  500. #ifdef NEEDED
  501.  
  502. /* open the clip region wide open for drawing */
  503.  
  504. saveclip()
  505. {
  506.     GetClip(soldclip);
  507.     ClipRect(&largerect);
  508. }
  509.  
  510. restoreclip()
  511. {
  512.     SetClip(soldclip);
  513. }
  514.  
  515. #endif
  516.  
  517. /* save the current font size */
  518.  
  519. savefont(ofont)
  520. struct fontsave * ofont;
  521. {
  522.     ofont->fontsize = ((GrafPtr) emwindow)->txSize;
  523.     ofont->fontid = ((GrafPtr) emwindow)->txFont;
  524.     TextSize(9);
  525.     TextFont(202);            /* our bold font CUB 9 */
  526. }
  527.  
  528. /* restore the current font size */
  529.  
  530. restorefont(ofont)
  531. struct fontsave * ofont;
  532. {
  533.     TextSize(ofont->fontsize);
  534.     TextFont(ofont->fontid);
  535. }
  536.  
  537. prettyinit()
  538. {
  539.     if (soldclip == (RgnHandle) NULL)
  540.         soldclip = NewRgn();
  541.  
  542.     largerect.top = -5000;
  543.     largerect.left = -5000;
  544.     largerect.bottom = 5000;
  545.     largerect.right = 5000;
  546.     
  547.     /* question mark box for triggering label draw */
  548.     
  549.     emdp->qmarkrect.top = -28;
  550.     emdp->qmarkrect.left = -12;
  551.     emdp->qmarkrect.bottom = -4; 
  552.     emdp->qmarkrect.right = -3;
  553.  
  554.     /* emdp->shrinkrect control */
  555.  
  556.     emdp->shrinkrect.top = PWSHRINKTOP;
  557.     emdp->shrinkrect.left = 485;
  558.     emdp->shrinkrect.bottom = PWSHRINKBOT;
  559.     emdp->shrinkrect.right = 498;
  560.     
  561.     emdp->h19right = 490;            /* right end of line at top of em area */
  562.     emdp->h19flagcenter = 489;
  563.     
  564.     /* rectangle for the Enter, Clear, etc. buttons at the top */
  565.  
  566.     emdp->toprect.top = -28;
  567.     emdp->toprect.left = -2;
  568.     emdp->toprect.bottom = -5;
  569.     emdp->toprect.right = 427;
  570.  
  571.     emdp->toprectbm.baseAddr = NewPtr(1920L);
  572.     emdp->toprectbm.rowBytes = 80;
  573.     emdp->toprectbm.bounds.top = 0;
  574.     emdp->toprectbm.bounds.left = 0;
  575.     emdp->toprectbm.bounds.bottom = 24;
  576.     emdp->toprectbm.bounds.right = 640;
  577.     
  578.     /* rectangle for the counters */
  579.     
  580.     emdp->countrect.top = -28;
  581.     emdp->countrect.left = 427;
  582.     emdp->countrect.bottom = -5;
  583.     emdp->countrect.right = 499;
  584.  
  585.     /* the blanking rectangles for input and output counts */
  586.     
  587.     emdp->incountrect.top = -20;        /* -27 */
  588.     emdp->incountrect.left = 462; 
  589.     emdp->incountrect.bottom = -10;    /* -7 */
  590.     emdp->incountrect.right = 497;
  591.  
  592.     emdp->outcountrect.top = -20;        /* -27 */
  593.     emdp->outcountrect.left = 429;
  594.     emdp->outcountrect.bottom = -10;    /* -7 */
  595.     emdp->outcountrect.right = 462;
  596.  
  597.     /* initialize rectangles which frame items on the right */
  598.  
  599.     emdp->shiftrect.top = PWSHIFTTOP;
  600.     emdp->shiftrect.left = PWLEFTMARG;
  601.     emdp->shiftrect.bottom = PWSHIFTBOT; 
  602.     emdp->shiftrect.right = PWRIGHTMARG;
  603.  
  604.     emdp->dubshiftrect.top = PWDUBSHIFTTOP;
  605.     emdp->dubshiftrect.left = PWLEFTMARG;
  606.     emdp->dubshiftrect.bottom = PWDUBSHIFTBOT; 
  607.     emdp->dubshiftrect.right = PWRIGHTMARG;
  608.  
  609.     emdp->macrorect.top = PWMACROTOP;
  610.     emdp->macrorect.left = PWLEFTMARG;
  611.     emdp->macrorect.bottom = PWMACROBOT; 
  612.     emdp->macrorect.right = PWRIGHTMARG;
  613.  
  614.     emdp->syslockrect.top = PWSYSLOCKTOP;
  615.     emdp->syslockrect.left = PWLEFTMARG;
  616.     emdp->syslockrect.bottom = PWSYSLOCKBOT; 
  617.     emdp->syslockrect.right = PWRIGHTMARG;
  618.  
  619.     emdp->kbdlockrect.top = PWKBDLOCKTOP;
  620.     emdp->kbdlockrect.left = PWLEFTMARG;
  621.     emdp->kbdlockrect.bottom = PWKBDLOCKBOT; 
  622.     emdp->kbdlockrect.right = PWRIGHTMARG;
  623. }
  624.  
  625.  
  626. /* shift things around so a resized window looks ok */
  627.  
  628. prettyresize(dh, dv)
  629. int dh;
  630. int dv;
  631. {
  632.     RgnPtr soldptr;
  633.     Rect eraser;
  634.     
  635.     emdp->controlschanged = TRUE;
  636.     
  637.     saveclip();
  638.     
  639.     if (line25on(emdp)) {
  640.         EraseRect(&emdp->toprect);
  641.         InvalRect(&emdp->toprect);
  642.     }
  643.     
  644.     /* erase the emulator portion of the window */
  645.     eraser.top = -4;
  646.     eraser.left = 0;
  647.     eraser.bottom = ((GrafPtr) emwindow)->portRect.bottom;
  648.     eraser.right = ((GrafPtr) emwindow)->portRect.right;
  649.  
  650.     EraseRect(&eraser);
  651.     trackon = FALSE;                /* show mouse tracking erased */
  652.     emdp->curson = FALSE;                    /* show cursor erased */
  653.     emdp->selrectvis = FALSE;                /* selrection rectangle erased */
  654.     
  655.      /* clear the line that forms the right hand box */
  656.  
  657.      emdp->h19right += dh;
  658.     emdp->h19flagcenter += dh;
  659.     
  660.     emdp->toprect.right += dh;
  661.     
  662.     /* emdp->countrect stuff */
  663.     
  664.     EraseRect(&emdp->countrect);
  665.     
  666.     emdp->countrect.left += dh;
  667.     emdp->countrect.right += dh;
  668.     emdp->incountrect.left += dh;
  669.     emdp->incountrect.right += dh;
  670.     emdp->outcountrect.left += dh;
  671.     emdp->outcountrect.right += dh;
  672.  
  673.     /* emdp->shrinkrect control */
  674.     
  675.     emdp->shrinkrect.left += dh;
  676.     emdp->shrinkrect.right += dh;
  677.  
  678.     /* initialize rectangles which frame items on the right */
  679.     emdp->shiftrect.left += dh;
  680.     emdp->shiftrect.right += dh;
  681.  
  682.     emdp->dubshiftrect.left += dh;
  683.     emdp->dubshiftrect.right += dh;
  684.  
  685.     emdp->macrorect.left += dh;
  686.     emdp->macrorect.right += dh;
  687.  
  688.     emdp->syslockrect.left += dh;
  689.     emdp->syslockrect.right += dh;
  690.  
  691.     emdp->kbdlockrect.left += dh;
  692.     emdp->kbdlockrect.right += dh;
  693.  
  694. #ifdef CLIPRESIZE
  695.     /* resize clip rect so new emulator area clipped properly */
  696.     soldptr = *soldclip;
  697.     SetRectRgn(soldclip, soldptr->rgnBBox.left, soldptr->rgnBBox.top, 
  698.         (short) (soldptr->rgnBBox.right + dh),
  699.         (short) (soldptr->rgnBBox.bottom + dv) );
  700. #endif
  701.  
  702.     restoreclip();
  703. }
  704.  
  705.  
  706. /* copy the control rectangle contents into a bitmap for speedier redrawing */
  707.  
  708. copytoprect(thewind)
  709. WindowPtr thewind;
  710. {
  711.     Point corner;
  712.     RgnHandle tstRgn;
  713.     RgnHandle intRgn;
  714.  
  715.     if (emwindow == NULL)
  716.         return;
  717.         
  718.     /* check to make sure the top rectangle is completely visible */
  719.     if ((tstRgn = NewRgn()) == NULL)
  720.         return(0);
  721.     if ((intRgn = NewRgn()) == NULL) {
  722.         DisposeRgn(tstRgn);
  723.         return(0);
  724.     }
  725.     RectRgn(tstRgn, &emdp->toprect);
  726.     SectRgn(((GrafPtr) emwindow)->visRgn, tstRgn, intRgn);
  727.     if (! EqualRgn(tstRgn, intRgn)) {
  728.         /* the whole emdp->toprect is not visible on the screen, so don't copy */
  729.         DisposeRgn(tstRgn);
  730.         DisposeRgn(intRgn);
  731.         return(0);
  732.     }
  733.     DisposeRgn(tstRgn);
  734.     DisposeRgn(intRgn);
  735.  
  736.     emdp->bmdestrect.top = emdp->toprect.top + 28;
  737.     emdp->bmdestrect.left = emdp->toprect.left + 2;
  738.     emdp->bmdestrect.bottom = emdp->toprect.bottom + 28;
  739.     emdp->bmdestrect.right = emdp->toprect.right + 2;
  740.  
  741.     CopyBits(&((GrafPtr) thewind)->portBits, &emdp->toprectbm, &emdp->toprect, &emdp->bmdestrect,
  742.         srcCopy, (RgnHandle) NULL);
  743.     emdp->controlschanged = FALSE;
  744. }
  745.  
  746.  
  747. /* paste the saved contents into a bitmap */
  748.  
  749. pastetoprect(thewind)
  750. WindowPtr thewind;
  751. {
  752.     CopyBits(&emdp->toprectbm, &((GrafPtr) thewind)->portBits, &emdp->bmdestrect, &emdp->toprect,
  753.         srcCopy, (RgnHandle) NULL);
  754. }
  755.  
  756.  
  757. /* a terminal connection has been made, draw the controls */
  758.  
  759. termwake()
  760. {
  761.     if (emwindow == NULL)
  762.         return;
  763.         
  764.     emdp->controlschanged = TRUE;
  765.     InvalRect(&emdp->toprect);
  766. }
  767.  
  768.  
  769. drawq1controls()
  770. {
  771.     struct fontsave ofont;
  772.     
  773.     if (emwindow == NULL)
  774.         return;
  775.         
  776.     savefont(&ofont);                
  777.     DrawControls(emwindow);
  778.     restorefont(&ofont);
  779. }
  780.  
  781. /* stubs for unused flag */
  782.  
  783. pfshowdubshift()
  784. {
  785. }
  786.  
  787. pfclrdubshift()
  788. {
  789. }
  790.  
  791.